Arrange for dialog boxes during emacsclient requests on Android
authorPo Lu <luangruo@yahoo.com>
Sun, 25 Feb 2024 03:41:02 +0000 (11:41 +0800)
committerPo Lu <luangruo@yahoo.com>
Sun, 25 Feb 2024 03:41:02 +0000 (11:41 +0800)
* lisp/server.el (server-execute): Bind use-dialog-box-override
if (featurep 'android).

* lisp/subr.el (use-dialog-box-override): New option.
(use-dialog-box-p): Always display dialog boxes if variable is
set.

lisp/server.el
lisp/subr.el

index 66e6d729f8abbcf3ab6bedf320a5b1ad002462fc..b65053267a60f03d0914a8d5c0d284aa0e9fb4c2 100644 (file)
@@ -1439,7 +1439,11 @@ invocations of \"emacs\".")
   ;; including code that needs to wait.
   (with-local-quit
     (condition-case err
-        (let ((buffers (server-visit-files files proc nowait)))
+        (let ((buffers (server-visit-files files proc nowait))
+              ;; On Android, the Emacs server generally can't provide
+              ;; feedback to the user except by means of dialog boxes,
+              ;; which are displayed in the GUI emacsclient wrapper.
+              (use-dialog-box-override (featurep 'android)))
           (mapc 'funcall (nreverse commands))
           (let ((server-eval-args-left (nreverse evalexprs)))
             (while server-eval-args-left
index c317d558e248b60633079e3a3923ae0de163284e..3031434365037665e53bb2cd1de7b85bc477d482 100644 (file)
@@ -3832,16 +3832,22 @@ confusing to some users.")
 
 (declare-function android-detect-keyboard "androidfns.c")
 
+(defvar use-dialog-box-override nil
+  "Whether `use-dialog-box-p' should always return t.")
+
 (defun use-dialog-box-p ()
   "Return non-nil if the current command should prompt the user via a dialog box."
-  (and last-input-event                 ; not during startup
-       (or (consp last-nonmenu-event)   ; invoked by a mouse event
-           (and (null last-nonmenu-event)
-                (consp last-input-event))
-           (and (featurep 'android)    ; Prefer dialog boxes on Android.
-                (not (android-detect-keyboard))) ; If no keyboard is connected.
-           from--tty-menu-p)            ; invoked via TTY menu
-       use-dialog-box))
+  (or use-dialog-box-override
+      (and last-input-event                 ; not during startup
+           (or (consp last-nonmenu-event)   ; invoked by a mouse event
+               (and (null last-nonmenu-event)
+                    (consp last-input-event))
+               (and (featurep 'android)        ; Prefer dialog boxes on
+                                        ; Android.
+                    (not (android-detect-keyboard))) ; If no keyboard is
+                                                     ; connected.
+               from--tty-menu-p)            ; invoked via TTY menu
+           use-dialog-box)))
 
 ;; Actually in textconv.c.
 (defvar overriding-text-conversion-style)